package com.bitnpulse.dev2.jjh.engstudybook_free.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.bitnpulse.dev2.jjh.engstudybook_free.common.Util;

public class SqlHelper extends SQLiteOpenHelper{
	
	
	public static final int DATABASE_VERSION 		= 1;
	
	public static final String DATABASE_NAME 		= "Study.db";
	public static final String TABLE_NAME 			= "repeat_info";
	
	public static final String ID 					= "id";
	public static final String SENTENCE_POSITION 	= "sentence_position";
	public static final String SENTENCE_FILE_PATH 	= "sentence_file_path";		
	
	
	public SqlHelper(Context ctx){
		super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
	}
	

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE " +  TABLE_NAME
				+ " ("
				+ ID 								+ " INTEGER PRIMARY KEY AUTOINCREMENT,"
				+ SENTENCE_POSITION					+ " TEXT,"
				+ SENTENCE_FILE_PATH				+ " TEXT"
				+ ");");
		Util.logPrn("SqlHelper.onCreate()");
	}
	
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
		onCreate(db);
		Util.logPrn("SqlHelper.onUpGrade()");
	}
}

